////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file	CollabRCBot\stdafx.h
///
/// @brief	Precompiled header file for the CollabRCBot program
////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "targetver.h"

#include <QtCore/QString>
#pragma warning(push)
#pragma warning(disable:4127)   // corelib/tools/qhash.h(743) : warning C4127: conditional expression is constant
#include <QtCore/QHash>
#pragma warning(pop)
#include <QtCore/QSet>
#include <QtCore/QReadWriteLock>
#include <cstdlib>
#include <exception>
#include <vector>
#include <cmath>
#include <assert.h>

/**
 * Creates a pseudorandom double on the interval [0,1]. 
 */
#define frand() (T::rand() / RAND_MAX)

/**
 * Creates a pseudorandom integer on the interval [a,b]. Requires that
 * b>=a or the function will malfunction.
 */
#define randint(a, b) (a + (int)((b-a+1) * (T::rand() / (RAND_MAX+1.0))))

/**
 * @brief Generates a pseudorandom double on the interval [10^-log10(e^n), e^n] using a logarithmic
 * probability distribution. 
 * 
 * The probability of obtaining a value on the interval
 * [1, 10) is approximately equivalent to that of [10, 100) and [100, 1000).
 *
 * @warning This formula is experimentally derived. Preferably a more
 * proven formula can be used.
 * @param n the natural log of the upper bound of the distribution
 */
#define lrand(n) (std::exp(n * (2 * frand() - 1)))

// 0.5lnx / lnn + 0.5 = y
// y - 0.5 = 0.5lnx/lnn
// 2y - 1 = lnx/lnn
// lnn * (2y - 1) = lnx
// e^(lnn * (2y - 1)) = x
// n ^ (2y - 1) = x
// but we prefer e^(lnn * (2y - 1)) because of the optimizations of e^v


/** @brief The natural log of 100 */
#define LN100 4.6051701859880913680359829093687